﻿using MediatR;
using SystemHYS.API.Application.command.ProductionOrdersCommand;
using SystemHYS.Domian;
using SystemHYS.Infrstructre.Interface;
namespace SystemHYS.API.Application.commandler.ProductionOrdersCommandler
{
    public class ProductionOrdersUpdateCommandler:IRequestHandler<ProductionOrdersUpdateCommand,int>
    {
        IProductionOrdersRepository OrdersRepository;

        public ProductionOrdersUpdateCommandler(IProductionOrdersRepository ordersRepository)
        {
            OrdersRepository = ordersRepository;
        }

        public async Task<int> Handle(ProductionOrdersUpdateCommand request, CancellationToken cancellationToken)
        {
            var list = new ProductionOrders()
            {
                ProductionOrdersId = request.ProductionOrdersId,
                ProductionNumber = request.ProductionNumber,
                Client = request.Client,
                OrderNumber = request.OrderNumber,
                Priority = request.Priority,
                remark = request.remark,
                AddName = "李明",
                AddTime = request.AddTime.Value.ToUniversalTime(),
            };
            return await OrdersRepository.UpdateAsyn(list);
        }
    }
}
